package org.giovanolli.mumi.controller.business;

import org.giovanolli.mumi.controller.AbstractController;
import org.giovanolli.mumi.controller.AbstractModel;
import org.giovanolli.mumi.entities.Speciality;
import org.giovanolli.mumi.entities.filter.SpecialityFilter;
import org.giovanolli.mumi.service.Service;
import org.giovanolli.mumi.service.SpecialityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("specialityController")
public class SpecialityController extends AbstractController<Speciality> {

	@Autowired
	private SpecialityService service;

	@Autowired
	private SpecialityModel model;

	@Override
	protected void bindEntityToModel() {
		Speciality editedSpeciality = model.getEditedEntity();
		model.setName(editedSpeciality.getName());
	}

	@Override
	protected void bindModelToEntity() {
		Speciality editedSpeciality = model.getEditedEntity();
		editedSpeciality.setName(model.getName().toUpperCase());
	}

	protected Class<Speciality> getEntityClass() {
		return Speciality.class;
	}

	@Override
	protected AbstractModel<Speciality> getModel() {
		return model;

	}

	@Override
	protected Service<Speciality> getService() {
		return service;
	}

	public void init() {
		super.init();
		model.setFilter(new SpecialityFilter());
	}
}
